/*
 * Copyright (c) 2023 iQi.Co.Ltd. All rights reserved.
 */
 
using IQIGame.Onigao.Framework;
using System.Collections.Generic;
using System.Linq;
using System;
using NetProtocol.Enum;

namespace NetProtocol.POD {

	/// <summary>
	///  编队中英雄数据
	/// module : structs
	/// </summary>
	public class FormationHeroPOD : IPOD 
    {
        public readonly static Func<FormationHeroPOD> FACTORY = () => new FormationHeroPOD();
		public static Func<FormationHeroPOD> DynamicFactory = FACTORY;
        
		/*-- members --*/
		/// <summary>
        ///  英雄唯一id
        /// </summary>
		public long id;
		/// <summary>
        ///  英雄cid--缓存
        /// </summary>
		public int cid;
		
		
		
		/*-- constructors --*/
		public FormationHeroPOD() {}
		public FormationHeroPOD(long id, int cid) {
			this.id = id;
			this.cid = cid;
		}
		  public void Serial(SOutputStream _out) {
                if(id != default) {
                    _out.WriteByte(1);
                    _out.Write_long(id);
                }
                if(cid != default) {
                    _out.WriteByte(2);
                    _out.Write_int(cid);
                }
        }
            
        public void UnSerial(SInputStream _in) {
            while (_in.HasRemaining())
            {
                int _key = _in.ReadByte();
                switch (_key)
                {
                    case 1:
                        id = _in.Read_long();
                        break;
                    case 2:
                        cid = _in.Read_int();
                        break;
                    default: _in.SkipBinary();break;
                }
            }
        }
		
		public FormationHeroPOD Clone() {
            FormationHeroPOD o = DynamicFactory();
            o.id = id;
            o.cid = cid;
            return o;
        }
        
        public void Clear() {
            id = default;
            cid = default;
        }
		
        public override string ToString() {
			string str = "";
			str += "FormationHeroPOD [";
			str += "id=";
			str += id;
			str += ", cid=";
			str += cid;
			str += "]";
			return str;
		}
		
	}
}